home *** CD-ROM | disk | FTP | other *** search
/ Experimental BBS Explossion 3 / Experimental BBS Explossion III.iso / games / nhak_src.zip / DO_WEAR.C < prev    next >
C/C++ Source or Header  |  1993-03-16  |  38KB  |  1,582 lines

  1. /*    SCCS Id: @(#)do_wear.c    3.0    88/05/10
  2. /* Copyright (c) Stichting Mathematisch Centrum, Amsterdam, 1985. */
  3. /* NetHack may be freely redistributed.  See license for details. */
  4.  
  5. #include "hack.h"
  6.  
  7. #ifdef OVLB
  8.  
  9. static int NEARDATA todelay;
  10.  
  11. #endif /*OVLB */
  12.  
  13. #ifndef OVLB
  14.  
  15. STATIC_DCL long takeoff_mask, taking_off;
  16.  
  17. #else /* OVLB */
  18.  
  19. STATIC_OVL long NEARDATA takeoff_mask = 0L, NEARDATA taking_off = 0L;
  20.  
  21. static const long NEARDATA takeoff_order[] = { WORN_BLINDF, 1L, /* weapon */
  22.     WORN_SHIELD, WORN_GLOVES, LEFT_RING, RIGHT_RING, WORN_CLOAK,
  23.     WORN_HELMET, WORN_AMUL, WORN_ARMOR,
  24. #ifdef SHIRT
  25.     WORN_SHIRT,
  26. #endif
  27.     WORN_BOOTS, 0L };
  28.  
  29. static void FDECL(on_msg, (struct obj *));
  30. STATIC_PTR int NDECL(Armor_on);
  31. STATIC_PTR int NDECL(Boots_on);
  32. static int NDECL(Cloak_on);
  33. STATIC_PTR int NDECL(Helmet_on);
  34. STATIC_PTR int NDECL(Gloves_on);
  35. static void NDECL(Amulet_on);
  36. static void FDECL(Ring_off_or_gone, (struct obj *, BOOLEAN_P));
  37. STATIC_PTR int FDECL(select_off, (struct obj *));
  38. static struct obj *NDECL(do_takeoff);
  39. STATIC_PTR int NDECL(take_off);
  40.  
  41. void
  42. off_msg(otmp) register struct obj *otmp; {
  43.     if(flags.verbose)
  44.         You("were wearing %s.", doname(otmp));
  45. }
  46.  
  47. /* for items that involve no delay */
  48. static void
  49. on_msg(otmp) register struct obj *otmp; {
  50.     if(flags.verbose)
  51.         You("are now wearing %s.", an(xname(otmp)));
  52. }
  53.  
  54. #endif /* OVLB */
  55. #ifdef OVL2
  56.  
  57. boolean
  58. is_boots(otmp) register struct obj *otmp; {
  59.     return(otmp->otyp >= LOW_BOOTS &&
  60.            otmp->otyp <= LEVITATION_BOOTS);
  61. }
  62.  
  63. boolean
  64. is_helmet(otmp) register struct obj *otmp; {
  65. #ifdef TOLKIEN
  66.     return(otmp->otyp >= ELVEN_LEATHER_HELM &&
  67.         otmp->otyp <= HELM_OF_TELEPATHY);
  68. #else
  69.     return(otmp->otyp >= ORCISH_HELM &&
  70.         otmp->otyp <= HELM_OF_TELEPATHY);
  71. #endif
  72. }
  73.  
  74. #endif /* OVLB */
  75. #ifdef OVL2
  76.  
  77. boolean
  78. is_gloves(otmp) register struct obj *otmp; {
  79.     return(otmp->otyp >= LEATHER_GLOVES &&
  80.            otmp->otyp <= GAUNTLETS_OF_DEXTERITY);
  81. }
  82.  
  83. #endif /* OVL2 */
  84. #ifdef OVLB
  85.  
  86. boolean
  87. is_cloak(otmp) register struct obj *otmp; {
  88.     return(otmp->otyp >= MUMMY_WRAPPING &&
  89.         otmp->otyp <= CLOAK_OF_DISPLACEMENT);
  90. }
  91.  
  92. boolean
  93. is_shield(otmp) register struct obj *otmp; {
  94.     return(otmp->otyp >= SMALL_SHIELD &&
  95.            otmp->otyp <= SHIELD_OF_REFLECTION);
  96. }
  97.  
  98. /*
  99.  * The Type_on() functions should be called *after* setworn().
  100.  * The Type_off() functions call setworn() themselves.
  101.  */
  102.  
  103. STATIC_PTR
  104. int
  105. Boots_on() {
  106.     long oldprop =
  107.         u.uprops[objects[uarmf->otyp].oc_oprop].p_flgs & ~(WORN_BOOTS | TIMEOUT);
  108.  
  109.     switch(uarmf->otyp) {
  110.     case LOW_BOOTS:
  111.     case IRON_SHOES:
  112.     case HIGH_BOOTS:
  113.     case WATER_WALKING_BOOTS:
  114.     case JUMPING_BOOTS:
  115.         break;
  116.     case SPEED_BOOTS:
  117.         if (!oldprop) {
  118.             makeknown(uarmf->otyp);
  119.             You("feel yourself speed up.");
  120.         }
  121.         break;
  122.     case ELVEN_BOOTS:
  123.         if (!oldprop) {
  124.             makeknown(uarmf->otyp);
  125.             You("walk very quietly.");
  126.         }
  127.         break;
  128.     case FUMBLE_BOOTS:
  129.         if (!oldprop)
  130.             Fumbling += rnd(20);
  131.         break;
  132.     case LEVITATION_BOOTS:
  133.         if (!oldprop) {
  134.             makeknown(uarmf->otyp);
  135.             float_up();
  136.         }
  137.         break;
  138.     default: impossible("Unknown type of boots (%d)", uarmf->otyp);
  139.     }
  140.     return 0;
  141. }
  142.  
  143. int
  144. Boots_off() {
  145.     register struct obj *obj = uarmf;
  146.     /* For levitation, float_down() returns if Levitation, so we
  147.      * must do a setworn() _before_ the levitation case.
  148.      */
  149.     long oldprop =
  150.         u.uprops[objects[uarmf->otyp].oc_oprop].p_flgs & ~(WORN_BOOTS | TIMEOUT);
  151.  
  152.     setworn((struct obj *)0, W_ARMF);
  153.     switch(obj->otyp) {
  154.     case SPEED_BOOTS:
  155.         if (!oldprop) {
  156.             makeknown(obj->otyp);
  157.             You("feel yourself slow down.");
  158.         }
  159.         break;
  160.     case WATER_WALKING_BOOTS:
  161.         if(is_pool(u.ux,u.uy) && !Levitation
  162. #ifdef POLYSELF
  163.             && !is_flyer(uasmon)
  164. #endif
  165.             ) {
  166.             makeknown(obj->otyp);
  167.             /* make boots known in case you survive the drowning */
  168.             drown();
  169.         }
  170.         break;
  171.     case ELVEN_BOOTS:
  172.         if (!oldprop) {
  173.             makeknown(obj->otyp);
  174.             You("sure are noisy.");
  175.         }
  176.         break;
  177.     case FUMBLE_BOOTS:
  178.         if (!oldprop)
  179.             Fumbling = 0;
  180.         break;
  181.     case LEVITATION_BOOTS:
  182.         if (!oldprop) {
  183.             (void) float_down();
  184.             makeknown(obj->otyp);
  185.         }
  186.         break;
  187.     case LOW_BOOTS:
  188.     case IRON_SHOES:
  189.     case HIGH_BOOTS:
  190.     case JUMPING_BOOTS:
  191.         break;
  192.     default: impossible("Unknown type of boots (%d)", obj->otyp);
  193.     }
  194.     return 0;
  195. }
  196.  
  197. static int
  198. Cloak_on() {
  199.     long oldprop = u.uprops[objects[uarmc->otyp].oc_oprop].p_flgs & ~WORN_CLOAK;
  200.  
  201.     switch(uarmc->otyp) {
  202.     case ELVEN_CLOAK:
  203.     case CLOAK_OF_PROTECTION:
  204.     case CLOAK_OF_DISPLACEMENT:
  205.         makeknown(uarmc->otyp);
  206.         break;
  207.     case MUMMY_WRAPPING:
  208. #ifdef TOLKIEN
  209.     case ORCISH_CLOAK:
  210.     case DWARVISH_CLOAK:
  211. #endif
  212.     case CLOAK_OF_MAGIC_RESISTANCE:
  213.         break;
  214.     case CLOAK_OF_INVISIBILITY:
  215.         if (!oldprop && !See_invisible && !Blind) {
  216.             makeknown(uarmc->otyp);
  217.             pline("Suddenly you cannot see yourself.");
  218.         }
  219.         break;
  220.     default: impossible("Unknown type of cloak (%d)", uarmc->otyp);
  221.     }
  222.     return 0;
  223. }
  224.  
  225. int
  226. Cloak_off() {
  227.     long oldprop = u.uprops[objects[uarmc->otyp].oc_oprop].p_flgs & ~WORN_CLOAK;
  228.  
  229.     switch(uarmc->otyp) {
  230.     case MUMMY_WRAPPING:
  231.     case ELVEN_CLOAK:
  232. #ifdef TOLKIEN
  233.     case ORCISH_CLOAK:
  234.     case DWARVISH_CLOAK:
  235. #endif
  236.     case CLOAK_OF_PROTECTION:
  237.     case CLOAK_OF_MAGIC_RESISTANCE:
  238.     case CLOAK_OF_DISPLACEMENT:
  239.         break;
  240.     case CLOAK_OF_INVISIBILITY:
  241.         if (!oldprop && !See_invisible && !Blind) {
  242.             makeknown(uarmc->otyp);
  243.             pline("Suddenly you can see yourself.");
  244.         }
  245.         break;
  246.     default: impossible("Unknown type of cloak (%d)", uarmc->otyp);
  247.     }
  248.     setworn((struct obj *)0, W_ARMC);
  249.     return 0;
  250. }
  251.  
  252. STATIC_PTR
  253. int
  254. Helmet_on() {
  255.     switch(uarmh->otyp) {
  256.     case FEDORA:
  257.     case HELMET:
  258. #ifdef TOLKIEN
  259.     case ELVEN_LEATHER_HELM:
  260.     case DWARVISH_IRON_HELM:
  261. #endif
  262.     case ORCISH_HELM:
  263.     case HELM_OF_TELEPATHY:
  264.         break;
  265.     case HELM_OF_BRILLIANCE:
  266.         if (uarmh->spe) {
  267.             ABON(A_INT) += uarmh->spe;
  268.             ABON(A_WIS) += uarmh->spe;
  269.             flags.botl = 1;
  270.             makeknown(uarmh->otyp);
  271.         }
  272.         break;
  273.     case HELM_OF_OPPOSITE_ALIGNMENT:
  274.         if (u.ualigntyp == U_NEUTRAL) u.ualigntyp = rn2(2) ? -1 : 1;
  275.         else u.ualigntyp = -(u.ualigntyp);
  276.         makeknown(uarmh->otyp);
  277.         flags.botl = 1;
  278.         break;
  279.     default: impossible("Unknown type of helm (%d)", uarmh->otyp);
  280.     }
  281.     return 0;
  282. }
  283.  
  284. int
  285. Helmet_off() {
  286.     switch(uarmh->otyp) {
  287.     case FEDORA:
  288.     case HELMET:
  289. #ifdef TOLKIEN
  290.     case ELVEN_LEATHER_HELM:
  291.     case DWARVISH_IRON_HELM:
  292. #endif
  293.     case ORCISH_HELM:
  294.     case HELM_OF_TELEPATHY:
  295.         break;
  296.     case HELM_OF_BRILLIANCE:
  297.         if (uarmh->spe) {
  298.             ABON(A_INT) -= uarmh->spe;
  299.             ABON(A_WIS) -= uarmh->spe;
  300.             flags.botl = 1;
  301.         }
  302.         break;
  303.     case HELM_OF_OPPOSITE_ALIGNMENT:
  304. #ifdef THEOLOGY
  305.         u.ualigntyp = u.ualignbase[0];
  306. #else
  307.         if (pl_character[0] == 'P' ||
  308.             pl_character[0] == 'T' ||
  309.             pl_character[0] == 'W')
  310.             u.ualigntyp = U_NEUTRAL;
  311.         else u.ualigntyp = -(u.ualigntyp);
  312. #endif
  313.         flags.botl = 1;
  314.         break;
  315.     default: impossible("Unknown type of helm (%d)", uarmh->otyp);
  316.     }
  317.     setworn((struct obj *)0, W_ARMH);
  318.     return 0;
  319. }
  320.  
  321. STATIC_PTR
  322. int
  323. Gloves_on() {
  324.     long oldprop =
  325.     u.uprops[objects[uarmg->otyp].oc_oprop].p_flgs & ~(WORN_GLOVES | TIMEOUT);
  326.  
  327.     switch(uarmg->otyp) {
  328.     case LEATHER_GLOVES:
  329.         break;
  330.     case GAUNTLETS_OF_FUMBLING:
  331.         if (!oldprop)
  332.             Fumbling += rnd(20);
  333.         break;
  334.     case GAUNTLETS_OF_POWER:
  335.         makeknown(uarmg->otyp);
  336.         flags.botl = 1; /* taken care of in attrib.c */
  337.         break;
  338.     case GAUNTLETS_OF_DEXTERITY:
  339.         if (uarmg->spe) makeknown(uarmg->otyp);
  340.         ABON(A_DEX) += uarmg->spe;
  341.         flags.botl = 1;
  342.         break;
  343.     default: impossible("Unknown type of gloves (%d)", uarmg->otyp);
  344.     }
  345.     return 0;
  346. }
  347.  
  348. int
  349. Gloves_off() {
  350.     long oldprop =
  351.     u.uprops[objects[uarmg->otyp].oc_oprop].p_flgs & ~(WORN_GLOVES | TIMEOUT);
  352.  
  353.     switch(uarmg->otyp) {
  354.     case LEATHER_GLOVES:
  355.         break;
  356.     case GAUNTLETS_OF_FUMBLING:
  357.         if (!oldprop)
  358.             Fumbling = 0;
  359.         break;
  360.     case GAUNTLETS_OF_POWER:
  361.         makeknown(uarmg->otyp);
  362.         flags.botl = 1; /* taken care of in attrib.c */
  363.         break;
  364.     case GAUNTLETS_OF_DEXTERITY:
  365.         if (uarmg->spe) makeknown(uarmg->otyp);
  366.         ABON(A_DEX) -= uarmg->spe;
  367.         flags.botl = 1;
  368.         break;
  369.     default: impossible("Unknown type of gloves (%d)", uarmg->otyp);
  370.     }
  371.     setworn((struct obj *)0, W_ARMG);
  372.     if (uwep && uwep->otyp == CORPSE && uwep->corpsenm == PM_COCKATRICE) {
  373.     /* Prevent wielding cockatrice when not wearing gloves */
  374.     You("wield the cockatrice corpse in your bare %s.",
  375.         makeplural(body_part(HAND)));
  376.     You("turn to stone...");
  377.     killer_format = KILLED_BY_AN;
  378.     killer = "cockatrice corpse";
  379.     done(STONING);
  380.     }
  381.     return 0;
  382. }
  383.  
  384. /*
  385. static int
  386. Shield_on() {
  387.     switch(uarms->otyp) {
  388.     case SMALL_SHIELD:
  389. #ifdef TOLKIEN
  390.     case ELVEN_SHIELD:
  391.     case URUK_HAI_SHIELD:
  392.     case ORCISH_SHIELD:
  393.     case DWARVISH_ROUNDSHIELD:
  394. #endif
  395.     case LARGE_SHIELD:
  396.     case SHIELD_OF_REFLECTION:
  397.         break;
  398.     default: impossible("Unknown type of shield (%d)", uarms->otyp);
  399.     }
  400.     return 0;
  401. }
  402. */
  403.  
  404. int
  405. Shield_off() {
  406. /*
  407.     switch(uarms->otyp) {
  408.     case SMALL_SHIELD:
  409. #ifdef TOLKIEN
  410.     case ELVEN_SHIELD:
  411.     case URUK_HAI_SHIELD:
  412.     case ORCISH_SHIELD:
  413.     case DWARVISH_ROUNDSHIELD:
  414. #endif
  415.     case LARGE_SHIELD:
  416.     case SHIELD_OF_REFLECTION:
  417.         break;
  418.     default: impossible("Unknown type of shield (%d)", uarms->otyp);
  419.     }
  420. */
  421.     setworn((struct obj *)0, W_ARMS);
  422.     return 0;
  423. }
  424.  
  425. /* This must be done in worn.c, because one of the possible intrinsics conferred
  426.  * is fire resistance, and we have to immediately set HFire_resistance in worn.c
  427.  * since worn.c will check it before returning.
  428.  */
  429. STATIC_PTR
  430. int
  431. Armor_on()
  432. {
  433.     return 0;
  434. }
  435.  
  436. int
  437. Armor_off()
  438. {
  439.     setworn((struct obj *)0, W_ARM);
  440.     return 0;
  441. }
  442.  
  443. /* The gone functions differ from the off functions in that if you die from
  444.  * taking it off and have life saving, you still die.
  445.  */
  446. int
  447. Armor_gone()
  448. {
  449.     setnotworn(uarm);
  450.     return 0;
  451. }
  452.  
  453. static void
  454. Amulet_on()
  455. {
  456.     char buf[BUFSZ];
  457.  
  458.     switch(uamul->otyp) {
  459.     case AMULET_OF_ESP:
  460.     case AMULET_OF_LIFE_SAVING:
  461.     case AMULET_VERSUS_POISON:
  462.     case AMULET_OF_REFLECTION:
  463.         break;
  464.     case AMULET_OF_CHANGE:
  465.         makeknown(AMULET_OF_CHANGE);
  466.         flags.female = !flags.female;
  467.         max_rank_sz();
  468.         /* Don't use same message as polymorph */
  469.         You("are suddenly very %s!", flags.female ? "feminine"
  470.             : "masculine");
  471.         if (pl_character[0]=='P')
  472.             Strcpy(pl_character+6, flags.female? "ess":"");
  473.         if (pl_character[0]=='C')
  474.             Strcpy(pl_character+5, flags.female ? "woman" : "man");
  475. #ifdef WIZARD
  476.         if (!wizard) {
  477. #endif
  478. newname:    more();
  479.         do {
  480.             pline("What shall you be called, %s? ",
  481.             flags.female ? "madam" : "sir");
  482.             getlin(buf);
  483.         } while (buf[0]=='\033' || buf[0]==0);
  484.         if (!strcmp(plname,buf)) {
  485.             pline("Sorry, that name no longer seems appropriate!");
  486.             goto newname;
  487.         }
  488.         flags.botl = 1;
  489.         (void)strncpy(plname, buf, sizeof(plname)-1);
  490. #ifdef VMS
  491.         Sprintf(SAVEF, "[.save]%d%s", getuid(), plname);
  492.         regularize(SAVEF+7);
  493.         Strcat(SAVEF, ";1");
  494. #else
  495. # ifdef MSDOS
  496.         (void)strcpy(SAVEF, SAVEP);
  497.         {
  498.             int i = strlen(SAVEF);
  499.             (void)strncat(SAVEF, plname, 8);
  500.             regularize(SAVEF+i);
  501.         }
  502.         (void)strcat(SAVEF, ".sav");
  503. # else
  504.         Sprintf(SAVEF, "save/%d%s", getuid(), plname);
  505.         regularize(SAVEF+5);        /* avoid . or / in name */
  506. # endif
  507. #endif
  508. #ifdef WIZARD
  509.         }
  510. #endif
  511.         pline("The amulet disintegrates!");
  512.         useup(uamul);
  513.         break;
  514.     case AMULET_OF_STRANGULATION:
  515.         makeknown(AMULET_OF_STRANGULATION);
  516.         pline("It constricts your throat!");
  517.         Strangled = 6;
  518.         break;
  519.     case AMULET_OF_RESTFUL_SLEEP:
  520.         Sleeping = rnd(100);
  521.         break;
  522.     case AMULET_OF_YENDOR:
  523.         break;
  524.     }
  525. }
  526.  
  527. void
  528. Amulet_off()
  529. {
  530.     switch(uamul->otyp) {
  531.     case AMULET_OF_ESP:
  532.     case AMULET_OF_LIFE_SAVING:
  533.     case AMULET_VERSUS_POISON:
  534.     case AMULET_OF_REFLECTION:
  535.         break;
  536.     case AMULET_OF_CHANGE:
  537.         impossible("Wearing an amulet of change?");
  538.         break;
  539.     case AMULET_OF_STRANGULATION:
  540.         if (Strangled) {
  541.             You("can breathe more easily!");
  542.             Strangled = 0;
  543.         }
  544.         break;
  545.     case AMULET_OF_RESTFUL_SLEEP:
  546.         Sleeping = 0;
  547.         break;
  548.     case AMULET_OF_YENDOR:
  549.         break;
  550.     }
  551.     setworn((struct obj *)0, W_AMUL);
  552. }
  553.  
  554. void
  555. Ring_on(obj)
  556. register struct obj *obj;
  557. {
  558.     long oldprop = u.uprops[objects[obj->otyp].oc_oprop].p_flgs & ~W_RING;
  559.  
  560.     switch(obj->otyp){
  561.     case RIN_TELEPORTATION:
  562.     case RIN_REGENERATION:
  563.     case RIN_SEARCHING:
  564.     case RIN_STEALTH:
  565.     case RIN_HUNGER:
  566.     case RIN_AGGRAVATE_MONSTER:
  567.     case RIN_POISON_RESISTANCE:
  568.     case RIN_FIRE_RESISTANCE:
  569.     case RIN_COLD_RESISTANCE:
  570.     case RIN_SHOCK_RESISTANCE:
  571.     case RIN_CONFLICT:
  572.     case RIN_WARNING:
  573.     case RIN_TELEPORT_CONTROL:
  574. #ifdef POLYSELF
  575.     case RIN_POLYMORPH:
  576.     case RIN_POLYMORPH_CONTROL:
  577. #endif
  578.         break;
  579.     case RIN_SEE_INVISIBLE:
  580.         if (Invis && !oldprop
  581. #ifdef POLYSELF
  582.                 && !perceives(uasmon)
  583. #endif
  584.                             && !Blind) {
  585.             newsym(u.ux,u.uy);
  586.             pline("Suddenly you can see yourself.");
  587.             makeknown(RIN_SEE_INVISIBLE);
  588.         }
  589.         break;
  590.     case RIN_INVISIBILITY:
  591.         if (!oldprop && !See_invisible && !Blind) {
  592.             makeknown(RIN_INVISIBILITY);
  593.             Your("body takes on a %s transparency...",
  594.                 Hallucination ? "normal" : "strange");
  595.         }
  596.         break;
  597.     case RIN_ADORNMENT:
  598.         ABON(A_CHA) += obj->spe;
  599.         flags.botl = 1;
  600.         if (obj->spe || objects[RIN_ADORNMENT].oc_name_known) {
  601.             makeknown(RIN_ADORNMENT);
  602.             obj->known = 1;
  603.         }
  604.         break;
  605.     case RIN_LEVITATION:
  606.         if(!oldprop) {
  607.             float_up();
  608.             makeknown(RIN_LEVITATION);
  609.             obj->known = 1;
  610.         }
  611.         break;
  612.     case RIN_GAIN_STRENGTH:
  613.         ABON(A_STR) += obj->spe;
  614.         flags.botl = 1;
  615.         if (obj->spe || objects[RIN_GAIN_STRENGTH].oc_name_known) {
  616.             makeknown(RIN_GAIN_STRENGTH);
  617.             obj->known = 1;
  618.         }
  619.         break;
  620.     case RIN_INCREASE_DAMAGE:
  621.         u.udaminc += obj->spe;
  622.         break;
  623.     case RIN_PROTECTION_FROM_SHAPE_CHAN:
  624.         rescham();
  625.         break;
  626.     case RIN_PROTECTION:
  627.         flags.botl = 1;
  628.         if (obj->spe || objects[RIN_PROTECTION].oc_name_known) {
  629.             makeknown(RIN_PROTECTION);
  630.             obj->known = 1;
  631.         }
  632.         break;
  633.     }
  634. }
  635.  
  636. static void
  637. Ring_off_or_gone(obj,gone)
  638. register struct obj *obj;
  639. boolean gone;
  640. {
  641.     register long mask = obj->owornmask & W_RING;
  642.  
  643.     if(!(u.uprops[objects[obj->otyp].oc_oprop].p_flgs & mask))
  644.     impossible("Strange... I didn't know you had that ring.");
  645.     if(gone) setnotworn(obj);
  646.     else setworn((struct obj *)0, obj->owornmask);
  647.     switch(obj->otyp) {
  648.     case RIN_TELEPORTATION:
  649.     case RIN_REGENERATION:
  650.     case RIN_SEARCHING:
  651.     case RIN_STEALTH:
  652.     case RIN_HUNGER:
  653.     case RIN_AGGRAVATE_MONSTER:
  654.     case RIN_POISON_RESISTANCE:
  655.     case RIN_FIRE_RESISTANCE:
  656.     case RIN_COLD_RESISTANCE:
  657.     case RIN_SHOCK_RESISTANCE:
  658.     case RIN_CONFLICT:
  659.     case RIN_WARNING:
  660.     case RIN_TELEPORT_CONTROL:
  661. #ifdef POLYSELF
  662.     case RIN_POLYMORPH:
  663.     case RIN_POLYMORPH_CONTROL:
  664. #endif
  665.         break;
  666.     case RIN_SEE_INVISIBLE:
  667.         if (Invisible && !Blind) {
  668.             pline("Suddenly you cannot see yourself.");
  669.             makeknown(RIN_SEE_INVISIBLE);
  670.         }
  671.         break;
  672.     case RIN_INVISIBILITY:
  673.         if (!(Invisible & ~W_RING) && !See_invisible && !Blind) {
  674.             Your("body seems to unfade...");
  675.             makeknown(RIN_INVISIBILITY);
  676.         }
  677.         break;
  678.     case RIN_ADORNMENT:
  679.         ABON(A_CHA) -= obj->spe;
  680.         flags.botl = 1;
  681.         break;
  682.     case RIN_LEVITATION:
  683.         (void) float_down();
  684.         if (!Levitation) makeknown(RIN_LEVITATION);
  685.         break;
  686.     case RIN_GAIN_STRENGTH:
  687.         ABON(A_STR) -= obj->spe;
  688.         flags.botl = 1;
  689.         break;
  690.     case RIN_INCREASE_DAMAGE:
  691.         u.udaminc -= obj->spe;
  692.         break;
  693.     case RIN_PROTECTION_FROM_SHAPE_CHAN:
  694.         /* If you're no longer protected, let the chameleons
  695.          * change shape again -dgk
  696.          */
  697.         restartcham();
  698.         break;
  699.     }
  700. }
  701.  
  702. void
  703. Ring_off(obj)
  704. struct obj *obj;
  705. {
  706.     Ring_off_or_gone(obj,FALSE);
  707. }
  708.  
  709. void
  710. Ring_gone(obj)
  711. struct obj *obj;
  712. {
  713.     Ring_off_or_gone(obj,TRUE);
  714. }
  715.  
  716. void
  717. Blindf_on(otmp) 
  718. register struct obj *otmp;
  719. {
  720.     setworn(otmp, W_TOOL);
  721.     on_msg(otmp);
  722.     seeoff(0);
  723. }
  724.  
  725. void
  726. Blindf_off(otmp) 
  727. register struct obj *otmp;
  728. {
  729.     setworn((struct obj *)0, otmp->owornmask);
  730.     off_msg(otmp);
  731.     if (!Blinded)    make_blinded(1L,FALSE); /* See on next move */
  732.     else        You("still cannot see.");
  733. }
  734.  
  735. /* called in main to set intrinsics of worn start-up items */
  736. void
  737. set_wear() {
  738.     if (uarm)  (void) Armor_on();
  739.     if (uarmc) (void) Cloak_on();
  740.     if (uarmf) (void) Boots_on();
  741.     if (uarmg) (void) Gloves_on();
  742.     if (uarmh) (void) Helmet_on();
  743. /*    if (uarms) (void) Shield_on(); */
  744. }
  745.  
  746. boolean
  747. donning(otmp)
  748. register struct obj *otmp;
  749. {
  750.     return (otmp == uarmf && (afternmv == Boots_on || afternmv == Boots_off))
  751.     || (otmp == uarmh && (afternmv == Helmet_on || afternmv == Helmet_off))
  752.     || (otmp == uarmg && (afternmv == Gloves_on || afternmv == Gloves_off))
  753.     || (otmp == uarm && (afternmv == Armor_on || afternmv == Armor_off));
  754. }
  755.  
  756. void
  757. cancel_don()
  758. {
  759.     /* the piece of armor we were donning/doffing has vanished, so stop
  760.      * wasting time on it (and don't dereference it when donning would
  761.      * otherwise finish)
  762.      */
  763.     afternmv = 0;
  764.     nomovemsg = NULL;
  765.     multi = 0;
  766. }
  767.  
  768. static const char NEARDATA clothes[] = {ARMOR_SYM, 0};
  769. static const char NEARDATA accessories[] = {RING_SYM, AMULET_SYM, TOOL_SYM, 0};
  770.  
  771. int
  772. dotakeoff() {
  773. #ifdef __GNULINT__
  774.     register struct obj *otmp = 0;
  775.         /* suppress "may be used uninitialized" warning */
  776. #else
  777.     register struct obj *otmp;
  778. #endif
  779.     int armorpieces = 0;
  780.  
  781. #define MOREARM(x) if (x) { armorpieces++; otmp = x; }
  782.     MOREARM(uarmh);
  783.     MOREARM(uarms);
  784.     MOREARM(uarmg);
  785.     MOREARM(uarmf);
  786.     if (uarmc) {
  787.         armorpieces++;
  788.         otmp = uarmc;
  789.     } else if (uarm) {
  790.         armorpieces++;
  791.         otmp = uarm;
  792. #ifdef SHIRT
  793.     } else if (uarmu) {
  794.         armorpieces++;
  795.         otmp = uarmu;
  796. #endif
  797.     }
  798.     if (!armorpieces) {
  799.         pline("Not wearing any armor.");
  800.         return 0;
  801.     }
  802.     if (armorpieces > 1)
  803.         otmp = getobj(clothes, "take off");
  804.     if (otmp == 0) return(0);
  805.     if (!(otmp->owornmask & W_ARMOR)) {
  806.         You("are not wearing that.");
  807.         return(0);
  808.     }
  809.     if (((otmp == uarm) && (uarmc))
  810. #ifdef SHIRT
  811.                 || ((otmp == uarmu) && (uarmc || uarm))
  812. #endif
  813.                                 ) {
  814.         You("can't take that off.");
  815.         return(0);
  816.     }
  817.     if(otmp == uarmg && welded(uwep)) {
  818.     You("seem unable to take off the gloves while holding your %s.",
  819.       is_sword(uwep) ? "sword" : "weapon");
  820.         uwep->bknown = 1;
  821.         return(0);
  822.     }
  823.     if(otmp == uarmg && Glib) {
  824.     You("can't remove the slippery gloves with your slippery fingers.");
  825.         return(0);
  826.     }
  827.     if(otmp == uarmf && u.utrap && u.utraptype == TT_BEARTRAP) {  /* -3. */
  828.         pline("The bear trap prevents you from pulling your foot out.");
  829.         return(0);
  830.     }
  831.     reset_remarm();            /* since you may change ordering */
  832.     (void) armoroff(otmp);
  833.     return(1);
  834. }
  835.  
  836. int
  837. doremring() {
  838. #ifdef __GNULINT__
  839.     register struct obj *otmp = 0;
  840.         /* suppress "may be used uninitialized" warning */
  841. #else
  842.     register struct obj *otmp;
  843. #endif
  844.     int Accessories = 0;
  845.  
  846. #define MOREACC(x) if (x) { Accessories++; otmp = x; }
  847.     MOREACC(uleft);
  848.     MOREACC(uright);
  849.     MOREACC(uamul);
  850.     MOREACC(ublindf);
  851.  
  852.     if(!Accessories) {
  853.         pline("Not wearing any accessories.");
  854.         return(0);
  855.     }
  856.     if (Accessories != 1) otmp = getobj(accessories, "take off");
  857.     if(!otmp) return(0);
  858.     if(!(otmp->owornmask & (W_RING | W_AMUL | W_TOOL))) {
  859.         You("are not wearing that.");
  860.         return(0);
  861.     }
  862.     if(cursed(otmp)) return(0);
  863.     if(otmp->olet == RING_SYM) {
  864. #ifdef POLYSELF
  865.         if (nolimbs(uasmon)) {
  866.             pline("It seems to be stuck.");
  867.             return(0);
  868.         }
  869. #endif
  870.         if (uarmg && uarmg->cursed) {
  871.             uarmg->bknown = 1;
  872. You("seem unable to remove your ring without taking off your gloves.");
  873.             return(0);
  874.         }
  875.         if (welded(uwep) && bimanual(uwep)) {
  876.             uwep->bknown = 1;
  877. You("seem unable to remove the ring while your hands hold your %s.",
  878.                 is_sword(uwep) ? "sword" : "weapon");
  879.             return(0);
  880.         }
  881.         if (welded(uwep) && otmp==uright) {
  882.             uwep->bknown = 1;
  883. You("seem unable to remove the ring while your right hand holds your %s.",
  884.                 is_sword(uwep) ? "sword" : "weapon");
  885.             return(0);
  886.         }
  887.         /* Sometimes we want to give the off_msg before removing and
  888.          * sometimes after; for instance, "you were wearing a moonstone
  889.          * ring (on right hand)" is desired but "you were wearing a
  890.          * square amulet (being worn)" is not because of the redundant
  891.          * "being worn".
  892.          */
  893.         off_msg(otmp);
  894.         Ring_off(otmp);
  895.     } else if(otmp->olet == AMULET_SYM) {
  896.         Amulet_off();
  897.         off_msg(otmp);
  898.     } else Blindf_off(otmp); /* does its own off_msg */
  899.     return(1);
  900. }
  901.  
  902. int
  903. cursed(otmp) register struct obj *otmp; {
  904.     /* Curses, like chickens, come home to roost. */
  905.     if(otmp->cursed){
  906.         You("can't.  %s to be cursed.",
  907.             (is_boots(otmp) || is_gloves(otmp) || otmp->quan > 1)
  908.             ? "They seem" : "It seems");
  909.         otmp->bknown = 1;
  910.         return(1);
  911.     }
  912.     return(0);
  913. }
  914.  
  915. int
  916. armoroff(otmp) register struct obj *otmp; {
  917.     register int delay = -objects[otmp->otyp].oc_delay;
  918.  
  919.     if(cursed(otmp)) return(0);
  920.     if(delay) {
  921.         nomul(delay);
  922.         if (is_helmet(otmp)) {
  923.             nomovemsg = "You finish taking off your helmet.";
  924.             afternmv = Helmet_off;
  925.              }
  926.         else if (is_gloves(otmp)) {
  927.             nomovemsg = "You finish taking off your gloves.";
  928.             afternmv = Gloves_off;
  929.              }
  930.         else if (is_boots(otmp)) {
  931.             nomovemsg = "You finish taking off your boots.";
  932.             afternmv = Boots_off;
  933.              }
  934.         else {
  935.             nomovemsg = "You finish taking off your suit.";
  936.             afternmv = Armor_off;
  937.         }
  938.     } else {
  939.         /* Be warned!  We want off_msg after removing the item to
  940.          * avoid "You were wearing ____ (being worn)."  However, an
  941.          * item which grants fire resistance might cause some trouble
  942.          * if removed in Hell and lifesaving puts it back on; in this
  943.          * case the message will be printed at the wrong time (after
  944.          * the messages saying you died and were lifesaved).  Luckily,
  945.          * no cloak, shield, or fast-removable armor grants fire
  946.          * resistance, so we can safely do the off_msg afterwards.
  947.          * Rings do grant fire resistance, but for rings we want the
  948.          * off_msg before removal anyway so there's no problem.  Take
  949.          * care in adding armors granting fire resistance; this code
  950.          * might need modification.
  951.          */
  952.         if(is_cloak(otmp))
  953.             (void) Cloak_off();
  954.         else if(is_shield(otmp))
  955.             (void) Shield_off();
  956.         else setworn((struct obj *)0, otmp->owornmask & W_ARMOR);
  957.         off_msg(otmp);
  958.     }
  959.     takeoff_mask = taking_off = 0L;
  960.     return(1);
  961. }
  962.  
  963. int
  964. dowear() {
  965.     register struct obj *otmp;
  966.     register int delay;
  967.     register int err = 0;
  968.     long mask = 0;
  969.  
  970. #ifdef POLYSELF
  971.     /* cantweararm checks for suits of armor */
  972.     /* verysmall or nohands checks for shields, gloves, etc... */
  973.     if ((verysmall(uasmon) || nohands(uasmon))) {
  974.         pline("Don't even bother.");
  975.         return(0);
  976.     }
  977. #endif
  978.     otmp = getobj(clothes, "wear");
  979.     if(!otmp) return(0);
  980. #ifdef POLYSELF
  981.     if (cantweararm(uasmon) && !is_shield(otmp) &&
  982.             !is_helmet(otmp) && !is_gloves(otmp) &&
  983.             !is_boots(otmp)) {
  984.         pline("The %s will not fit on your body.",
  985.             is_cloak(otmp) ? "cloak" :
  986. # ifdef SHIRT
  987.             otmp->otyp == HAWAIIAN_SHIRT ? "shirt" :
  988. # endif
  989.             "suit");
  990.         return(0);
  991.     }
  992. #endif
  993.     if(otmp->owornmask & W_ARMOR) {
  994.         You("are already wearing that!");
  995.         return(0);
  996.     }
  997.     if(is_helmet(otmp)) {
  998.         if(uarmh) {
  999.             You("are already wearing a helmet.");
  1000.             err++;
  1001.         } else
  1002.             mask = W_ARMH;
  1003.     } else if(is_shield(otmp)){
  1004.         if(uarms) {
  1005.             You("are already wearing a shield.");
  1006.             err++;
  1007.         }
  1008.         if(uwep && bimanual(uwep)) {
  1009.         You("cannot hold a shield and wield a two-handed %s.",
  1010.               is_sword(uwep) ? "sword" : "weapon");
  1011.             err++;
  1012.         }
  1013.         if(!err) mask = W_ARMS;
  1014.     } else if(is_boots(otmp)) {
  1015.            if(uarmf) {
  1016.             You("are already wearing boots.");
  1017.             err++;
  1018.            } else
  1019.             mask = W_ARMF;
  1020.     } else if(is_gloves(otmp)) {
  1021.         if(uarmg) {
  1022.             You("are already wearing gloves.");
  1023.             err++;
  1024.         } else
  1025.         if(uwep && uwep->cursed) {
  1026.             You("cannot wear gloves over your %s.",
  1027.                   is_sword(uwep) ? "sword" : "weapon");
  1028.             err++;
  1029.         } else
  1030.             mask = W_ARMG;
  1031. #ifdef SHIRT
  1032.     } else if( otmp->otyp == HAWAIIAN_SHIRT ) {
  1033.         if (uarm || uarmc || uarmu) {
  1034.             if(!uarm && !uarmc) /* then uarmu */
  1035.                You("are already wearing a shirt.");
  1036.             else
  1037.                You("can't wear that over your %s.",
  1038.                  (uarm && !uarmc) ? "armor" : "cloak");
  1039.             err++;
  1040.         } else
  1041.             mask = W_ARMU;
  1042. #endif
  1043.     } else if(is_cloak(otmp)) {
  1044.         if(uarmc) {
  1045.             You("are already wearing a cloak.");
  1046.             err++;
  1047.         } else
  1048.             mask = W_ARMC;
  1049.     } else {
  1050.         if(uarmc) {
  1051.             You("cannot wear armor over a cloak.");
  1052.             err++;
  1053.         } else if(uarm) {
  1054.             You("are already wearing some armor.");
  1055.             err++;
  1056.         }
  1057.         if(!err) mask = W_ARM;
  1058.     }
  1059. /* Unnecessary since now only weapons and special items like pick-axes get
  1060.  * welded to your hand, not armor
  1061.     if(welded(otmp)) {
  1062.         if(!err++)
  1063.             weldmsg(otmp, FALSE);
  1064.     }
  1065.  */
  1066.     if(err) return(0);
  1067.  
  1068.     otmp->known = 1;
  1069.     if(otmp == uwep)
  1070.         setuwep((struct obj *)0);
  1071.     setworn(otmp, mask);
  1072.     delay = -objects[otmp->otyp].oc_delay;
  1073.     if(delay){
  1074.         nomul(delay);
  1075.         if(is_boots(otmp)) afternmv = Boots_on;
  1076.         if(is_helmet(otmp)) afternmv = Helmet_on;
  1077.         if(is_gloves(otmp)) afternmv = Gloves_on;
  1078.         if(otmp == uarm) afternmv = Armor_on;
  1079.         nomovemsg = "You finish your dressing maneuver.";
  1080.     } else {
  1081.         if(is_cloak(otmp)) (void) Cloak_on();
  1082. /*        if(is_shield(otmp)) (void) Shield_on(); */
  1083.         on_msg(otmp);
  1084.     }
  1085.     takeoff_mask = taking_off = 0L;
  1086.     return(1);
  1087. }
  1088.  
  1089. int
  1090. doputon() {
  1091.     register struct obj *otmp;
  1092.     long mask = 0;
  1093.  
  1094.     if(uleft && uright && uamul && ublindf) {
  1095. #ifdef POLYSELF
  1096.         Your("%s%s are full, and you're already wearing an amulet and a blindfold.",
  1097.             (humanoid(uasmon) || u.usym==S_CENTAUR) ? "ring-" : "",
  1098.             makeplural(body_part(FINGER)));
  1099. #else
  1100.         Your("ring-fingers are full, and you're already wearing an amulet and a blindfold.");
  1101. #endif
  1102.         return(0);
  1103.     }
  1104.     otmp = getobj(accessories, "wear");
  1105.     if(!otmp) return(0);
  1106.     if(otmp->owornmask & (W_RING | W_AMUL | W_TOOL)) {
  1107.         You("are already wearing that!");
  1108.         return(0);
  1109.     }
  1110.     if(welded(otmp)) {
  1111.         weldmsg(otmp, TRUE);
  1112.         return(0);
  1113.     }
  1114.     if(otmp == uwep)
  1115.         setuwep((struct obj *)0);
  1116.     if(otmp->olet == RING_SYM) {
  1117. #ifdef POLYSELF
  1118.         if(nolimbs(uasmon)) {
  1119.             You("cannot make the ring stick to your body.");
  1120.             return(0);
  1121.         }
  1122. #endif
  1123.         if(uleft && uright){
  1124. #ifdef POLYSELF
  1125.             pline("There are no more %s%s to fill.",
  1126.                 (humanoid(uasmon) || u.usym==S_CENTAUR)
  1127.                     ? "ring-" : "",
  1128.                 makeplural(body_part(FINGER)));
  1129. #else
  1130.             pline("There are no more ring-fingers to fill.");
  1131. #endif
  1132.             return(0);
  1133.         }
  1134.         if(uleft) mask = RIGHT_RING;
  1135.         else if(uright) mask = LEFT_RING;
  1136.         else do {
  1137.             char answer;
  1138.  
  1139. #ifdef POLYSELF
  1140.             pline("What %s%s, Right or Left? ",
  1141.                 (humanoid(uasmon) || u.usym==S_CENTAUR)
  1142.                     ? "ring-" : "",
  1143.                 body_part(FINGER));
  1144. #else
  1145.             pline("What ring-finger, Right or Left? ");
  1146. #endif
  1147.             if(index(quitchars, (answer = readchar())))
  1148.                 return(0);
  1149.             switch(answer){
  1150.             case 'l':
  1151.             case 'L':
  1152.                 mask = LEFT_RING;
  1153.                 break;
  1154.             case 'r':
  1155.             case 'R':
  1156.                 mask = RIGHT_RING;
  1157.                 break;
  1158.             }
  1159.         } while(!mask);
  1160.         if (uarmg && uarmg->cursed) {
  1161.             uarmg->bknown = 1;
  1162.             You("cannot remove your gloves to put on the ring.");
  1163.             return(0);
  1164.         }
  1165.         if (welded(uwep) && bimanual(uwep)) {
  1166.             /* welded will set bknown */
  1167.         You("cannot free your weapon hands to put on the ring.");
  1168.             return(0);
  1169.         }
  1170.         if (welded(uwep) && mask==RIGHT_RING) {
  1171.             /* welded will set bknown */
  1172.         You("cannot free your weapon hand to put on the ring.");
  1173.             return(0);
  1174.         }
  1175.         setworn(otmp, mask);
  1176.         Ring_on(otmp);
  1177.     } else if (otmp->olet == AMULET_SYM) {
  1178.         if(uamul) {
  1179.             You("are already wearing an amulet.");
  1180.             return(0);
  1181.         }
  1182.         setworn(otmp, W_AMUL);
  1183.         if (otmp->otyp == AMULET_OF_CHANGE) {
  1184.             Amulet_on();
  1185.             /* Don't do a prinv() since the amulet is now gone */
  1186.             return(1);
  1187.         }
  1188.         Amulet_on();
  1189.     } else {    /* it's a blindfold */
  1190.         if (ublindf) {
  1191.             You("are already wearing a blindfold.");
  1192.             return(0);
  1193.         }
  1194.         if (otmp->otyp != BLINDFOLD) {
  1195.             You("can't wear that!");
  1196.             return(0);
  1197.         }
  1198.         Blindf_on(otmp);
  1199.         return(1);
  1200.     }
  1201.     prinv(otmp);
  1202.     return(1);
  1203. }
  1204.  
  1205. #endif /* OVLB */
  1206.  
  1207. #define ARM_BONUS(obj)    ((10 - objects[obj->otyp].a_ac) + obj->spe)
  1208.  
  1209. #ifdef OVL0
  1210.  
  1211. void
  1212. find_ac() {
  1213.     register int uac = 10;
  1214. #ifdef POLYSELF
  1215.     if (u.mtimedone) uac = mons[u.umonnum].ac;
  1216. #endif
  1217.     if(uarm) uac -= ARM_BONUS(uarm);
  1218.     if(uarmc) uac -= ARM_BONUS(uarmc);
  1219.     if(uarmh) uac -= ARM_BONUS(uarmh);
  1220.     if(uarmf) uac -= ARM_BONUS(uarmf);
  1221.     if(uarms) uac -= ARM_BONUS(uarms);
  1222.     if(uarmg) uac -= ARM_BONUS(uarmg);
  1223. #ifdef SHIRT
  1224.     if(uarmu) uac -= ARM_BONUS(uarmu);
  1225. #endif
  1226.     if(uleft && uleft->otyp == RIN_PROTECTION) uac -= uleft->spe;
  1227.     if(uright && uright->otyp == RIN_PROTECTION) uac -= uright->spe;
  1228. #ifdef THEOLOGY
  1229.     if (Protection & INTRINSIC) uac -= u.ublessed;
  1230. #endif
  1231.     if(uac != u.uac){
  1232.         u.uac = uac;
  1233.         flags.botl = 1;
  1234.     }
  1235. }
  1236.  
  1237. #endif /* OVL0 */
  1238. #ifdef OVLB
  1239.  
  1240. void
  1241. glibr()
  1242. {
  1243.     register struct obj *otmp;
  1244.     int xfl = 0;
  1245. #ifdef HARD
  1246.     boolean leftfall, rightfall;
  1247.  
  1248.     leftfall = (uleft && !uleft->cursed && (!uwep || !uwep->cursed
  1249.         || !bimanual(uwep)));
  1250.     rightfall = (uright && !uright->cursed && (!uwep || !uwep->cursed));
  1251. #else
  1252. #define leftfall uleft
  1253. #define rightfall uright
  1254. #endif
  1255.     if(!uarmg) if(leftfall || rightfall)
  1256. #ifdef POLYSELF
  1257.                 if(!nolimbs(uasmon))
  1258. #endif
  1259.                         {
  1260.         /* Note: at present also cursed rings fall off */
  1261.         /* changed 10/30/86 by GAN */
  1262.         Your("%s off your %s.",
  1263.             (leftfall && rightfall) ? "rings slip" : "ring slips",
  1264.             makeplural(body_part(FINGER)));
  1265.         xfl++;
  1266.         if(leftfall) {
  1267.             otmp = uleft;
  1268.             Ring_off(uleft);
  1269.             dropx(otmp);
  1270.         }
  1271.         if(rightfall) {
  1272.             otmp = uright;
  1273.             Ring_off(uright);
  1274.             dropx(otmp);
  1275.         }
  1276.     }
  1277.     if(((otmp = uwep) != (struct obj *)0)
  1278. #ifdef HARD
  1279.        && !otmp->cursed
  1280. #endif
  1281.     ) {
  1282.         /* Note: at present also cursed weapons fall */
  1283.         /* changed 10/30/86 by GAN */
  1284.         Your("%s %sslips from your %s.",
  1285.             is_sword(uwep) ? "sword" : "weapon",
  1286.             xfl ? "also " : "",
  1287.             makeplural(body_part(HAND)));
  1288.         setuwep((struct obj *)0);
  1289.         dropx(otmp);
  1290.     }
  1291. }
  1292.  
  1293. struct obj *
  1294. some_armor(){
  1295. register struct obj *otmph = (uarmc ? uarmc : uarm);
  1296.     if(uarmh && (!otmph || !rn2(4))) otmph = uarmh;
  1297.     if(uarmg && (!otmph || !rn2(4))) otmph = uarmg;
  1298.     if(uarmf && (!otmph || !rn2(4))) otmph = uarmf;
  1299.     if(uarms && (!otmph || !rn2(4))) otmph = uarms;
  1300. #ifdef SHIRT
  1301.     if(!uarm && !uarmc && uarmu && (!otmph || !rn2(4))) otmph = uarmu;
  1302. #endif
  1303.     return(otmph);
  1304. }
  1305.  
  1306. void
  1307. corrode_armor(){
  1308. register struct obj *otmph = some_armor();
  1309.  
  1310.     if (otmph && otmph != uarmf) {
  1311.         if (otmph->rustfree || objects[otmph->otyp].oc_material != METAL ||
  1312.         otmph->otyp >= LEATHER_ARMOR) {
  1313.             Your("%s not affected!",
  1314.                 aobjnam(otmph, "are"));
  1315.             return;
  1316.         }
  1317.         Your("%s!", aobjnam(otmph, "corrode"));
  1318.         otmph->spe--;
  1319.         adj_abon(otmph, -1);
  1320.     }
  1321. }
  1322.  
  1323. STATIC_PTR
  1324. int
  1325. select_off(otmp)
  1326. register struct obj *otmp;
  1327. {
  1328.     if(!otmp) return(0);
  1329.     if(cursed(otmp)) return(0);
  1330. #ifdef POLYSELF
  1331.     if(otmp->olet==RING_SYM && nolimbs(uasmon)) return(0);
  1332. #endif
  1333.     if(welded(uwep) && (otmp==uarmg || otmp==uright || (otmp==uleft
  1334.             && bimanual(uwep))))
  1335.         return(0);
  1336.     if(uarmg && uarmg->cursed && (otmp==uright || otmp==uleft)) {
  1337.         uarmg->bknown = 1;
  1338.         return(0);
  1339.     }
  1340.     if((otmp==uarm 
  1341. #ifdef SHIRT
  1342.             || otmp==uarmu
  1343. #endif
  1344.                     ) && uarmc && uarmc->cursed) {
  1345.         uarmc->bknown = 1;
  1346.         return(0);
  1347.     }
  1348. #ifdef SHIRT
  1349.     if(otmp==uarmu && uarm && uarm->cursed) {
  1350.         uarm->bknown = 1;
  1351.         return(0);
  1352.     }
  1353. #endif
  1354.  
  1355.     if(otmp == uarm) takeoff_mask |= WORN_ARMOR;
  1356.     else if(otmp == uarmc) takeoff_mask |= WORN_CLOAK;
  1357.     else if(otmp == uarmf) takeoff_mask |= WORN_BOOTS;
  1358.     else if(otmp == uarmg) takeoff_mask |= WORN_GLOVES;
  1359.     else if(otmp == uarmh) takeoff_mask |= WORN_HELMET;
  1360.     else if(otmp == uarms) takeoff_mask |= WORN_SHIELD;
  1361. #ifdef SHIRT
  1362.     else if(otmp == uarmu) takeoff_mask |= WORN_SHIRT;
  1363. #endif
  1364.     else if(otmp == uleft) takeoff_mask |= LEFT_RING;
  1365.     else if(otmp == uright) takeoff_mask |= RIGHT_RING;
  1366.     else if(otmp == uamul) takeoff_mask |= WORN_AMUL;
  1367.     else if(otmp == ublindf) takeoff_mask |= WORN_BLINDF;
  1368.     else if(otmp == uwep) takeoff_mask |= 1L;    /* WIELDED_WEAPON */
  1369.  
  1370.     else impossible("select_off: %s???", doname(otmp));
  1371.  
  1372.     return(0);
  1373. }
  1374.  
  1375. static struct obj *
  1376. do_takeoff() {
  1377.  
  1378.     register struct obj *otmp = 0;
  1379.  
  1380.     if (taking_off == 1L) { /* weapon */
  1381.       if(!cursed(uwep)) {
  1382.         setuwep((struct obj *) 0);
  1383.         You("are empty %s.", body_part(HANDED));
  1384.       }
  1385.     } else if (taking_off ==  WORN_ARMOR) {
  1386.       otmp = uarm;
  1387.       if(!cursed(otmp)) (void) Armor_off();
  1388.     } else if (taking_off == WORN_CLOAK) {
  1389.       otmp = uarmc;
  1390.       if(!cursed(otmp)) (void) Cloak_off();
  1391.     } else if (taking_off == WORN_BOOTS) {
  1392.       otmp = uarmf;
  1393.       if(!cursed(otmp)) (void) Boots_off();
  1394.     } else if (taking_off == WORN_GLOVES) {
  1395.       otmp = uarmg;
  1396.       if(!cursed(otmp)) (void) Gloves_off();
  1397.     } else if (taking_off == WORN_HELMET) {
  1398.       otmp = uarmh;
  1399.       if(!cursed(otmp)) (void) Helmet_off();
  1400.     } else if (taking_off == WORN_SHIELD) {
  1401.       otmp = uarms;
  1402.       if(!cursed(otmp)) (void) Shield_off();
  1403. #ifdef SHIRT
  1404.     } else if (taking_off == WORN_SHIRT) {
  1405.       otmp = uarmu;
  1406.       if(!cursed(otmp))
  1407.         setworn((struct obj *)0, uarmu->owornmask & W_ARMOR);
  1408. #endif
  1409.     } else if (taking_off == WORN_AMUL) {
  1410.       otmp = uamul;
  1411.       if(!cursed(otmp)) Amulet_off();
  1412.     } else if (taking_off == LEFT_RING) {
  1413.       otmp = uleft;
  1414.       if(!cursed(otmp)) Ring_off(uleft);
  1415.     } else if (taking_off == RIGHT_RING) {
  1416.       otmp = uright;
  1417.       if(!cursed(otmp)) Ring_off(uright);
  1418.     } else if (taking_off == WORN_BLINDF) {
  1419.       if(!cursed(ublindf)) {
  1420.         setworn((struct obj *)0, ublindf->owornmask);
  1421.         if(!Blinded) make_blinded(1L,FALSE); /* See on next move */
  1422.         else     You("still cannot see.");
  1423.       }
  1424.     } else impossible("do_takeoff: taking off %lx", taking_off);
  1425.  
  1426.     return(otmp);
  1427. }
  1428.  
  1429. STATIC_PTR
  1430. int
  1431. take_off() {
  1432.  
  1433.     register int i;
  1434.     register struct obj *otmp;
  1435.  
  1436.     if(taking_off) {
  1437.         if(todelay > 0) {
  1438.  
  1439.         todelay--;
  1440.         return(1);    /* still busy */
  1441.         } else if((otmp = do_takeoff())) off_msg(otmp);
  1442.  
  1443.         takeoff_mask &= ~taking_off;
  1444.         taking_off = 0L;
  1445.     }
  1446.  
  1447.     for(i = 0; takeoff_order[i]; i++)
  1448.         if(takeoff_mask & takeoff_order[i]) {
  1449.  
  1450.         taking_off = takeoff_order[i];
  1451.         break;
  1452.         }
  1453.  
  1454.     otmp = (struct obj *) 0;
  1455.  
  1456.     if (taking_off == 0L) {
  1457.       You("finish disrobing.");
  1458.       return 0;
  1459.     } else if (taking_off == 1L) {
  1460.       todelay = 1;
  1461.     } else if (taking_off == WORN_ARMOR) {
  1462.       otmp = uarm;
  1463.     } else if (taking_off == WORN_CLOAK) {
  1464.       otmp = uarmc;
  1465.     } else if (taking_off == WORN_BOOTS) {
  1466.       otmp = uarmf;
  1467.     } else if (taking_off == WORN_GLOVES) {
  1468.       otmp = uarmg;
  1469.     } else if (taking_off == WORN_HELMET) {
  1470.       otmp = uarmh;
  1471.     } else if (taking_off == WORN_SHIELD) {
  1472.       otmp = uarms;
  1473. #ifdef SHIRT
  1474.     } else if (taking_off == WORN_SHIRT) {
  1475.       otmp = uarmu;
  1476. #endif
  1477.     } else if (taking_off == WORN_AMUL) {
  1478.       todelay = 1;
  1479.     } else if (taking_off == LEFT_RING) {
  1480.       todelay = 1;
  1481.     } else if (taking_off == RIGHT_RING) {
  1482.       todelay = 1;
  1483.     } else if (taking_off == WORN_BLINDF) {
  1484.       todelay = 2;
  1485.     } else {
  1486.       impossible("take_off: taking off %lx", taking_off);
  1487.       return 0;    /* force done */
  1488.     }
  1489.  
  1490.     if(otmp) todelay = objects[otmp->otyp].oc_delay;
  1491.     set_occupation(take_off, "disrobing", 0);
  1492.     return(1);        /* get busy */
  1493. }
  1494.  
  1495. #endif /* OVLB */
  1496. #ifdef OVL1
  1497.  
  1498. void
  1499. reset_remarm() { taking_off = takeoff_mask =0L; }
  1500.  
  1501. #endif /* OVL1 */
  1502. #ifdef OVLB
  1503.  
  1504. int
  1505. doddoremarm() {
  1506.  
  1507.     if(taking_off || takeoff_mask) {
  1508.  
  1509.         You("continue disrobing.");
  1510.         set_occupation(take_off, "disrobing", 0);
  1511.         return(take_off());
  1512.     }
  1513.  
  1514.     (void) ggetobj("take off", select_off, 0);
  1515.     if(takeoff_mask) return(take_off());
  1516.     else         return(0);
  1517. }
  1518.  
  1519. int
  1520. destroy_arm(atmp)
  1521. register struct obj *atmp;
  1522. {
  1523.     register struct obj *otmp;
  1524.  
  1525.     if((otmp = uarmc) && (!atmp || atmp == uarmc)) {
  1526.         Your("cloak crumbles and turns to dust!");
  1527.         (void) Cloak_off();
  1528.         useup(otmp);
  1529.     } else if((otmp = uarm) && (!atmp || atmp == uarm)) {
  1530.         /* may be disintegrated by spell or dragon breath... */
  1531.         if (donning(otmp)) cancel_don();
  1532.         Your("armor turns to dust and falls to the floor!");
  1533.         (void) Armor_gone();
  1534.         useup(otmp);
  1535. #ifdef SHIRT
  1536.     } else if((otmp = uarmu) && (!atmp || atmp == uarmu)) {
  1537.         Your("shirt crumbles into tiny threads and falls apart!");
  1538.         useup(otmp);
  1539. #endif
  1540.     } else if((otmp = uarmh) && (!atmp || atmp == uarmh)) {
  1541.         if (donning(otmp)) cancel_don();
  1542.         Your("helmet turns to dust and is blown away!");
  1543.         (void) Helmet_off();
  1544.         useup(otmp);
  1545.     } else if((otmp = uarmg) && (!atmp || atmp == uarmg)) {
  1546.         if (donning(otmp)) cancel_don();
  1547.         Your("gloves vanish!");
  1548.         (void) Gloves_off();
  1549.         useup(otmp);
  1550.         selftouch("You");
  1551.     } else if((otmp = uarmf) && (!atmp || atmp == uarmf)) {
  1552.         if (donning(otmp)) cancel_don();
  1553.         Your("boots disintegrate!");
  1554.         (void) Boots_off();
  1555.         useup(otmp);
  1556.     } else if((otmp =uarms) && (!atmp || atmp == uarms)) {
  1557.         Your("shield crumbles away!");
  1558.         (void) Shield_off();
  1559.         useup(otmp);
  1560.     } else     return(0);        /* could not destroy anything */
  1561.  
  1562.     return(1);
  1563. }
  1564.  
  1565. void
  1566. adj_abon(otmp, delta)
  1567. register struct obj *otmp;
  1568. register schar delta;
  1569. {
  1570.     if (uarmg && otmp->otyp == GAUNTLETS_OF_DEXTERITY) {
  1571.         ABON(A_DEX) += (delta);
  1572.         flags.botl = 1;
  1573.     }
  1574.     if (uarmh && otmp->otyp == HELM_OF_BRILLIANCE) {
  1575.         ABON(A_INT) += (delta);
  1576.         ABON(A_WIS) += (delta);
  1577.         flags.botl = 1;
  1578.     }
  1579. }
  1580.  
  1581. #endif /* OVLB */
  1582.